<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main"/>

    <g:set var="entityName" value="${message(code: 'opportunity.label', default: 'Opportunity')}"/>
    <title>车辆贷款（主单页）-opportunityLayout38</title>
</head>

<body>
<input type="hidden" value="${this.opportunity?.id}" id="opportunityId">

<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb m-t-none">
                    <li>贷款管理系统</li>
                    <li>
                        <g:link controller="opportunityTeam" action="index">订单管理</g:link>
                    </li>
                    <li class="active">
                        <span>信息查看</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light">
                订单号: ${this.opportunity.serialNumber}
            <span style="font-weight: normal" class="text-info">
                【${this.opportunity?.stage?.description}】
                【保护期： <g:if test="${this.opportunity?.protectionEndTime > new Date()}">
                ${this.opportunity?.protectionEndTime - this.opportunity?.protectionStartTime}天
                </g:if>】
                <g:if test="${this.opportunity?.status == 'Failed'}">【订单结果：<span
                        class="text-danger">失败</span>】</span></g:if>
                <g:elseif test="${this.opportunity?.status == 'Completed'}">【订单结果：成功】</g:elseif>
                <g:else>【订单结果：进行中】</g:else>
            </span>
                <g:link target="_blank" class="btn btn-xs btn-warning" controller="opportunity"
                        action="opportunityLayout39"
                        id="${this.opportunity?.id}">订单推进</g:link>
                <g:if test="${this.opportunity?.isTest}">
                    <span class="label label-danger"><i class="fa fa-star"></i> 测试 <i class="fa fa-star"></i></span>
                </g:if>
            </h2>

        </div>
    </div>
</div>

<div class="content animate-panel">
    <div class="row">
        <g:if test="${flash.message}">
            <div class="message alert alert-info" role="status">${flash.message}
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
            </div>
        </g:if>
        <div class="hpanel hred">
            <div class="panel-heading">
                <div class="panel-tools">
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                业务概要
                <g:if test="${this.opportunity?.status == 'Failed'}">
                    <span class="failReason text-danger">订单失败：${this.opportunity?.causeOfFailure?.name}</span>
                </g:if>
            </div>

            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered text-center">
                        <thead>
                        <tr>
                            <th>业务区域</th>
                            <th>业务来源</th>
                            <th>抵押类型</th>
                            <th>
                                申请金额（元）
                            </th>
                            <th>拟借款金额（元）</th>
                            <th>拟借款期数（月）</th>
                            <th>渠道返费(元)</th>
                            <th>产品类型</th>
                            <th>共同借款人</th>
                            %{--<th>实际月息（%）</th>--}%
                            <th>付息方式</th>
                            <g:if test="${this.opportunity?.interestPaymentMethod?.name == '上扣息'}">
                                <th>上扣息月份数（月）</th>
                            </g:if>
                            <th>资金渠道</th>
                            <th>客户评级</th>

                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>${this.opportunity?.houses[0]?.city?.name}</td>
                            <td>${this.opportunity?.contact?.account?.name}</td>
                            <td>
                                <g:each in="${this.houses}">
                                    ${it?.mortgageType?.name}、
                                </g:each>
                            </td>
                            <td>
                                <g:formatNumber number="${this.opportunity?.loanAmount}" minFractionDigits="2"
                                                maxFractionDigits="2"/>
                            </td>
                            <td>
                                <g:formatNumber number="${this.opportunity?.requestedAmount}" minFractionDigits="2"
                                                maxFractionDigits="2"/>
                            </td>
                            <td>
                                ${this.opportunity?.loanDuration}
                            </td>
                            <td>
                                <g:each in="${opportunityProduct}">
                                    <g:if test="${it?.productInterestType?.name == '渠道返费费率'}">
                                        <g:if test="${!it?.installments}">一次性;<g:formatNumber
                                                number="${it.rate * this.opportunity.actualAmountOfCredit / 100}"
                                                minFractionDigits="2"
                                                maxFractionDigits="9"/></g:if>
                                        <g:else>月月返;<g:formatNumber
                                                number="${it.rate * this.opportunity.actualAmountOfCredit * this.opportunity.actualLoanDuration / 100}"
                                                minFractionDigits="2"
                                                maxFractionDigits="9"/></g:else>
                                    </g:if>
                                </g:each>
                            </td>
                            <td>${this.opportunity?.product?.name}</td>

                            <td>
                                <g:each in="${this.opportunityContacts}"><g:if
                                        test="${!(it?.type?.name == '曾用名')}"><span class="nameFormat">${it?.contact?.fullName}</span>、</g:if></g:each>
                            </td>
                            %{--<td><g:formatNumber number="${this.opportunity?.monthlyInterest}" maxFractionDigits="9"/></td>--}%
                            <td>
                                ${this.opportunity?.interestPaymentMethod?.name}
                            </td>
                            <g:if test="${this.opportunity?.interestPaymentMethod?.name == '上扣息'}">
                                <td>${this.opportunity?.monthOfAdvancePaymentOfInterest}</td>
                            </g:if>
                            <td>
                                <g:each in="${this.opportunityFlexFieldCategorys}">
                                    <g:if test="${it?.flexFieldCategory?.name == '资金渠道'}">
                                        <g:each in="${it?.fields}" var="field">
                                            <g:if test="${field?.name == '放款通道'}">
                                                ${field?.value}、
                                            </g:if>
                                        </g:each>
                                        <g:each in="${it?.fields}" var="field">
                                            <g:if test="${field?.name == '放款账号'}">
                                                ${field?.value}
                                            </g:if>
                                        </g:each>
                                    </g:if>

                                </g:each>
                            </td>
                            <td>${this.opportunity?.lender?.level?.description}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="hpanel hred">
            <div class="panel-heading">
                <div class="panel-tools">
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                经纪人信息
            </div>

            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered text-center">
                        <thead>
                        <tr>
                            <th>经纪人姓名</th>
                            <th>经纪人电话</th>
                            <th>支持经理姓名</th>
                            <th>
                                支持经理电话
                            </th>

                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td><span class="nameFormat">${this.opportunity?.contact?.fullName}</span></td>
                            <td>${this.opportunity?.contact?.cellphone}</td>
                            <td><span class="nameFormat">${this.opportunity?.user}</span></td>
                            <td>${this.opportunity?.user?.cellphone}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="row" id="fourth">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                  <g:link class="btn btn-info btn-xs" controller="ruleEngineProvider"
                          action="evaluate" id="${this.opportunity.id}"><i
                          class="fa fa-database"></i>决策引擎</g:link>
                        <g:if test="${this.opportunity.contacts?.size() > 0}">
                            <g:link target=" _blank" class="btn btn-info btn-xs" controller="creditReportConstraint"
                                    action="creditReportShow" id="${this.opportunity.id}"><i
                                    class="fa fa-database"></i>大数据</g:link>
                        </g:if>

                            <g:link class="btn btn-info btn-xs" controller="opportunityContact" action="create"
                                    params="[opportunity: this.opportunity.id]"><i class="fa fa-plus"></i>新增</g:link>

                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                借款人及抵押人信息
            </div>

            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover text-center">
                        <thead>
                        <tr>
                            <g:sortableColumn property="type" title="联系人"></g:sortableColumn>
                            <g:sortableColumn property="fullName" title="姓名"></g:sortableColumn>
                            <g:sortableColumn property="idNumber" title="身份证号"></g:sortableColumn>
                            <g:sortableColumn property="cellphone" title="手机号"></g:sortableColumn>
                            <g:sortableColumn property="maritalStatus" title="婚否"></g:sortableColumn>
                            <g:sortableColumn property="age" title="年龄(岁)"></g:sortableColumn>
                            <g:sortableColumn property="profession" title="职业"></g:sortableColumn>
                            <g:sortableColumn property="country" title="国籍"></g:sortableColumn>
                            <g:sortableColumn property="identityType" title="身份证件类型"></g:sortableColumn>
                            <g:sortableColumn property="monthlyIncome" title="月收入（元）"></g:sortableColumn>
                            <g:sortableColumn property="connectedType" title="新客户"></g:sortableColumn>
                            <g:sortableColumn property="isBlackList" title="反欺诈结果"></g:sortableColumn>
                            <g:sortableColumn property="level" title="是否VIP"></g:sortableColumn>

                                    <g:sortableColumn width="8%" class="text-center" property="operation" colspan="2"
                                                      title="操作"></g:sortableColumn>
                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${this.opportunityContacts}">
                            <tr>
                                <td>
                                    <sec:ifNotGranted roles="ROLE_COO">
                                        <g:link controller="opportunityContact" action="show"
                                                id="${it?.id}">${it?.type?.name}</g:link>
                                    </sec:ifNotGranted>
                                    <sec:ifAllGranted roles="ROLE_COO">
                                        ${it?.type?.name}
                                    </sec:ifAllGranted>
                                </td>
                                <td>
                                    <span class="nameFormat">${it?.contact?.fullName}</span>
                                </td>
                                <td  class="certificateFormat">
                                    ${it?.contact?.idNumber}
                                </td>
                                <td class="cellphoneFormat">
                                    ${it?.contact?.cellphone}
                                </td>
                                <td>
                                    ${it?.contact?.maritalStatus}
                                </td>
                                <td>
                                    <g:if test="${it?.contact?.idNumber}">
                                        ${new Date().format("yyyy").toInteger().minus(it?.contact?.idNumber[6..9].toInteger())}
                                    </g:if>
                                    <g:else>
                                        ${it?.contact?.idNumber}
                                    </g:else>
                                </td>
                                <td>
                                    ${it?.contact?.profession?.name}
                                </td>
                                <td>
                                    ${it?.contact?.country?.name}
                                </td>
                                <td>
                                    ${it?.contact?.identityType?.name}
                                </td>
                                <td>
                                    ${it?.contact?.monthlyIncome}
                                </td>
                                <td>
                                  <g:if test="${it?.contact?.clientType == 'new'}">是</g:if><g:else>否</g:else>
                                </td>
                                <td><g:if test="${it?.contact?.isBlackList}">命中</g:if><g:else>未命中</g:else></td>
                                <td><g:if test="${it?.contact?.level?.name=='A'}">是</g:if><g:else>否</g:else></td>
                                    <td class="text-center">
                                      <g:link class="btn btn-primary btn-outline btn-xs" controller="opportunityContact" action="show"
                                              id="${it?.id}">央行征信</g:link>

                                    </td>

                                        <td class="text-center">
                                            <g:form resource="${it}" method="DELETE">
                                                <button class="deleteBtn btn btn-danger btn-xs btn-outline" type="button"><i
                                                        class="fa fa-trash-o"></i> 删除</button>
                                            </g:form>
                                        </td>

                            </tr>
                        </g:each>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <g:each in="${this.opportunityFlexFieldCategorys}">
        <g:if test="${(it?.flexFieldCategory?.name =='决策引擎结果')}">

            <div class="row" id="">
                <div class="hpanel hyellow">
                    <div class="panel-heading hbuilt">
                        <div class="panel-tools">

                        </div>
                        ${it?.flexFieldCategory?.name}
                    </div>

                    <div class="panel-body no-padding">
                        <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover text-center">
                            <thead>
                            <tr>
                            <th>策略名</th>
                            <th>决策场景</th>
                            <th>风险阈值</th>
                            <th>评级</th>
                            <th>申请额度（元）</th>
                            <th>评分结果</th>
                            <th>债务收入比</th>
                            <th>还款期限</th>

                            </tr>
                            </thead>
                            <tbody>

                                <tr>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'ProcessCode'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'Decision'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'RiskArea'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'Rating'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'RequestedAmount'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'StructScoreRawScore'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'DTI'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'Term'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>

                                </tr>

                            </tbody>
                        </table>
                        </div>
                    </div>
                </div>
            </div>
        </g:if>
    </g:each>

    <g:render template="/layouts/opportunityTemplate/housesTemplate4"/>
    <g:render template="/layouts/opportunityTemplate/opportunityProductTemplate"/>

    <div class="row">
        <g:each in="${this.opportunityFlexFieldCategorys}">
            <g:if test="${it?.flexFieldCategory?.name == '产调结果'}">
                <div class="hpanel hyellow collapsed">
                    <div class="panel-heading hbuilt">
                        <div class="panel-tools">
                            <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                        </div>
                        产调信息
                    </div>

                    <div class="panel-body no-padding">
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover text-center">
                                <thead>
                                <tr>
                                    <g:sortableColumn width="30%" property="executionSequence"
                                                      title="${message(code: 'opportunityFlexField.name.label', default: '产调核查内容')}"/>
                                    <g:sortableColumn width="70%" property="stage"
                                                      title="${message(code: 'opportunityFlexField.value.label', default: '审核结果')}"/>
                                </tr>
                                </thead>
                                <tbody>
                                <g:each in="${it?.fields}">
                                    <tr>
                                        <td>
                                            <g:link controller="opportunityFlexField" action="show" id="${it?.id}"
                                                    class="firstTd">${it?.name}</g:link>
                                        </td>
                                        <td>${it?.value}</td>
                                    </tr>
                                </g:each>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </g:if>
        </g:each>
    </div>

    <g:render template="/layouts/opportunityTemplate/opportunityContractsTemplate"/>

    <div class="row" id="eighth">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                    <sec:ifNotGranted roles="ROLE_COO">
                        <g:link class="btn btn-info btn-xs" controller="attachments" action="create"
                                id="${this.opportunity.id}"><i class="fa fa-upload"></i>上传</g:link>
                    </sec:ifNotGranted>
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                附件信息
            </div>

            <div class="panel-body no-padding">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="horange">
                            <div class="panel-body float-e-margins" style="border-top: none;">
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '房产证']">房产证</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '身份证']">身份证</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '户口本']">户口本</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '婚姻证明']">婚姻证明</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '被执情况']">被执情况</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '驾驶证']">驾驶证</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '征信报告']">征信报告</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '大数据']">大数据</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '借款合同']">借款合同</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '公证书']">公证书</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '他项证明']">他项证明</g:link>

                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '其他资料']">其他资料</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '车辆评估证明']">车辆评估证明</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '购车合同']">购车合同</g:link>
                                <g:link target=" _blank" class="btn btn-outline btn-primary" controller="attachments"
                                        action="show" id="${this.opportunity.id}"
                                        params="[attachmentTypeName: '行驶证']">行驶证</g:link>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>







    <div class="row">
        <div class="hpanel horange">
            <div class="panel-heading">
                <div class="panel-tools">
                    <g:link params="[flag: 'shibai']" id="${this.opportunity?.id}" controller="opportunity"
                            action="edit" class="btn btn-info btn-xs"><i
                            class="fa fa-edit"></i>编辑</g:link>
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>

                </div>
                失败原因
            </div>

            <div class="panel-body form-horizontal p-xs">
                <div class="form-group">
                    <label class="col-md-3 control-label">未成交归类：</label>

                    <div class="col-md-2">
                        <span class="cont">${this.opportunity?.causeOfFailure?.name}</span>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <g:render template="/layouts/opportunityTemplate/opportunityTeamTemlpate"/>
    <g:render template="/layouts/opportunityTemplate/activitiesTemplate"/>
    <g:render template="/layouts/opportunityTemplate/opportunityFlowsTemplate"/>


</div>
<footer class="footer bg-success">
    <g:render template="/layouts/opportunityTemplate/footerRightTemplate"/>
</footer>

<script>
    $(function () {
        $("body").addClass("fixed-small-header");
        if ($(".commentsContent").children().length < 1) {
            $(".commentsContent").closest(".commentsRow").remove();
        }
    })
</script>
</body>

</html>
